<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增企业招聘')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-companyrecruit-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">公司ID：</label>
                <div class="col-sm-8">
                    <input name="companyId" class="form-control" type="text" readonly="readonly" th:value="${company.id}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">公司名称：</label>
                <div class="col-sm-8">
                    <input name="companyName" class="form-control"  th:value="${company.companyName}" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">招聘标题：</label>
                <div class="col-sm-8">
                    <input name="title" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">最高薪资：</label>
                <div class="col-sm-8">
                    <input name="salaryMax" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">最低薪资：</label>
                <div class="col-sm-8">
                    <input name="salaryMin" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">薪资单位：</label>
                <div class="col-sm-8">
                    <input name="salaryUnit" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">浏览量：</label>
                <div class="col-sm-8">
                    <input name="views" class="form-control" type="text" value="0">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">行业ID：</label>
                <div class="col-sm-8">
<!--                    <input name="industry" class="form-control" type="text" required>-->
                    <select name="industry" class="form-control m-b">
                        <option th:each="dict : ${recruitIndustries}" th:text="${dict.name}" th:value="${dict.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工作省份：</label>
                <div class="col-sm-8">
<!--                    <input name="province" class="form-control" type="text">-->
                    <select name="province" class="form-control m-b" onchange="showCity(this.value)">
                        <option>请选择工作省份</option>
                        <option th:each="dict : ${provinces}" th:text="${dict.name}" th:value="${dict.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工作城市：</label>
                <div class="col-sm-8">
<!--                    <input name="city" class="form-control" type="text">-->
                    <select name="city" class="form-control m-b" onchange="showArea(this.value)" id="city">
                        <option>请选择工作城市</option>

                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工作区县：</label>
                <div class="col-sm-8">
<!--                    <input name="area" class="form-control" type="text">-->
                    <select name="area" class="form-control m-b" id="area">
                        <option>请选择工作区县</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">学历要求：</label>
                <div class="col-sm-8">
                    <input name="education" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">经验要求：</label>
                <div class="col-sm-8">
                    <input name="experience" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">招聘人数：</label>
                <div class="col-sm-8">
                    <input name="peoNum" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">职位详情：</label>
<!--                <div class="col-sm-8">-->
<!--                    <input name="info" class="form-control" type="text">-->
<!--                </div>-->
                <div class="col-sm-8">
                    <div class="ibox-content no-padding">
                        <div class="summernote">

                        </div>
                    </div>
                    <input id="info" name="info" class="form-control" type="hidden">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-8">
                    <input name="phone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">发布时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="createAt" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">修改时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="updateAt" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态0-已发布1-已结束2-已驳回：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('recruit_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "jiaqin/companyrecruit";
        var cityList = [[${@regionServiceImpl.selectCityList()}]];
        var areaList = [[${@regionServiceImpl.selectAreaList()}]];


        $(document).ready(function () {
            $('.summernote').summernote({
                height: 300,
                lang: 'zh-CN',
                callbacks: {
                    onChange: function(contents, $editable) {
                        // console.log('onChange:', contents, $editable);
                        var aHTML = $('.summernote').summernote('code');
                        console.log(aHTML);
                        $("#info").val(aHTML);
                    }
                }
            });
        });

        $("#form-companyrecruit-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-companyrecruit-add').serialize());
            }
        }

        $("input[name='createAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='updateAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function showCity(pid){
            // var scityList = new Array();
            // for (i=0;i<cityList.length;i++){
            //     if(pid == cityList[i].pid){
            //         scityList.push(cityList[i]);
            //     }
            // }
            // var scityList = new Array();
            var str = "<option>请选择工作城市</option>";
            for (i=0;i<cityList.length;i++){
                if(pid == cityList[i].pid){
                    // scityList.push(cityList[i]);
                    str+="<option value='"+cityList[i].id+"'>"+cityList[i].name+"</option>";
                }
            }
            // console.log(scityList);
            //渲染DOM
            $("#city").html("");
            $("#area").html("");
            $("#city").append(str);
            $("#area").append("<option>请选择工作区县</option>");
        }

        function showArea(pid){
            // var scityList = new Array();
            // for (i=0;i<cityList.length;i++){
            //     if(pid == cityList[i].pid){
            //         scityList.push(cityList[i]);
            //     }
            // }
            // var scityList = new Array();
            var str = "<option>请选择工作区县</option>";
            for (i=0;i<areaList.length;i++){
                if(pid == areaList[i].pid){
                    // scityList.push(cityList[i]);
                    str+="<option value='"+areaList[i].id+"'>"+areaList[i].name+"</option>";
                }
            }
            // console.log(scityList);
            //渲染DOM
            $("#area").html("");
            $("#area").append(str);
        }
    </script>
</body>
</html>
